<template>
	<!-- 手动模式 -->
	<view class="p-40">
		<view class="f-blod">手动模式开锁参数</view>
		<view class="card">
			<view class="item-box">
				<view class="">动作时间(ms)</view>
				<input type="number" class="u-text-right" v-model="unlockActionTime" />
			</view>
			<view class="item-box">
				<view class="">间隔时间(ms)</view>
				<input type="number" class="u-text-right" v-model="unlockGapTime" />
			</view>
			<view class="item-box">
				<view class="">点击重复次数</view>
				<input type="number" class="u-text-right" v-model="unlockCount" />
			</view>
		</view>
		<view class="f-blod m-t-30">手动模式关锁参数</view>
		<view class="card">
			<view class="item-box">
				<view class="">动作时间(ms)</view>
				<input type="number" class="u-text-right" v-model="lockActionTime" />
			</view>
			<view class="item-box">
				<view class="">间隔时间(ms)</view>
				<input type="number" class="u-text-right" v-model="lockGapTime" />
			</view>
			<view class="item-box">
				<view class="">点击重复次数</view>
				<input type="number" class="u-text-right" v-model="lockCount" />
			</view>
		</view>
		<view class="bottom-box">
			<u-button type="primary" @click="handleSubmit">保存</u-button>
		</view>
	</view>
</template>

<script>
	import {
		getUuid,
		writeBLECharacteristicValue
	} from "../../utils/common";
	export default {
		data() {
			return {
				unlockActionTime: 0,
				unlockGapTime: 0,
				unlockCount: 0,
				lockActionTime: 0,
				lockGapTime: 0,
				lockCount: 0,
			};
		},
		onLoad() {

		},
		methods: {
			handleSubmit() {
				const serviceId = getUuid("5508");
				writeBLECharacteristicValue(serviceId, getUuid("0010"), parseInt(this.unlockActionTime));
				writeBLECharacteristicValue(serviceId, getUuid("0011"), parseInt(this.unlockGapTime));
				writeBLECharacteristicValue(serviceId, getUuid("0012"), parseInt(this.unlockCount));
				writeBLECharacteristicValue(serviceId, getUuid("0013"), parseInt(this.lockActionTime));
				writeBLECharacteristicValue(serviceId, getUuid("0014"), parseInt(this.lockGapTime));
				writeBLECharacteristicValue(serviceId, getUuid("0015"), parseInt(this.lockCount));
				writeBLECharacteristicValue(serviceId, getUuid("FF10"), "", "保存");

			},
		}
	}
</script>

<style lang="scss" scoped>
	.card {
		background-color: white;
		box-shadow: 0px 3px 8px 0px rgba(0, 0, 0, 0.16);
		border-radius: 10rpx;
		margin-top: 15rpx;
		padding: 30rpx;
	}

	.item-box {
		border-bottom: 1px solid #f8f8f8;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 20rpx 0;
	}

	.bottom-box {
		position: fixed;
		bottom: 40rpx;
		width: 670rpx;
	}
</style>